<?php
class page_login Extends page_Base {
    
    var $access_max = 0;

    public function index() {
        $z = $this->tp->apply_sys('form_login');
        $this->tp->g_add('content',$z);
    }


    public function getSettings(){

    }

    public function doLogin() {
        $login = trim($_POST['login']);
        $pass = trim($_POST['pass']);

        if(preg_match('/^[a-zA-Z0-9]+$/',$login) == 0 ) {
            $error .= 'Invalid User Name ! <br /><br />';
        }

        if(preg_match('/^[a-zA-Z0-9]+$/',$pass) == 0 ) {
            $error .= 'Invalid password ! <br /><br />';
        }

        $user = $this->registry->get('user');
        $msg = $user->Login($login,$pass);
        $config = $this->registry->get('config');
        
        if(!empty($msg)) {
            $this->tp->g_add('content',$msg);
        }
        else {
            header("Location: {$config['misc']['site_url']}?p=user/home");
        }

    }
}
?>
